//
//  AppDelegate.m
//  LOL_PalmarHelper
//
//  Created by dllo on 15/6/19.
//  Copyright (c) 2015年 hantao. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

-(void)dealloc
{

    [_window release];
    [super dealloc];


}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

    [NSThread sleepForTimeInterval:2.0];

    [UMSocialData setAppKey:@"559a76b067e58e5d91002844"];
    
    
    
//    559a76b067e58e5d91002844
    
    
        
//--------------创建tabBar------------
    
    NewsViewController *newsVC = [[NewsViewController alloc] init];
    UINavigationController *newsNav = [[UINavigationController alloc] initWithRootViewController:newsVC];
    newsNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"资讯" image:[UIImage imageNamed:@"iconfont-zixun.png"] tag:10001];
    
    [newsNav.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar1.png"] forBarMetrics:UIBarMetricsDefault];
  
       VideoViewController *videoVc = [[VideoViewController alloc] init];
    UINavigationController *videoNav = [[UINavigationController alloc] initWithRootViewController:videoVc];
    videoNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"视频" image:[UIImage imageNamed:@"iconfont-shipin.png"] tag:10002];
    [videoNav.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar1.png"] forBarMetrics:UIBarMetricsDefault];
    
    
    HeroViewController *heroVC = [[HeroViewController alloc] init];
    UINavigationController *heroNav = [[UINavigationController alloc] initWithRootViewController:heroVC];
    heroNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"英雄" image:[UIImage imageNamed:@"iconfont-shejishi-2"] tag:10003];
     [heroNav.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar1.png"] forBarMetrics:UIBarMetricsDefault];
    
    
    MoreViewController *moreVC = [[MoreViewController alloc] init];
    UINavigationController *moreNav = [[UINavigationController alloc] initWithRootViewController:moreVC];
    moreNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"更多" image:[UIImage imageNamed:@"iconfont-gengduo-2.png"] tag:10004];
     [moreNav.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar1.png"] forBarMetrics:UIBarMetricsDefault];
    
  
    
    
    

    
    
    
    UITabBarController *myTabBar = [[UITabBarController alloc] init];

    myTabBar.viewControllers = [NSMutableArray arrayWithObjects:newsNav,heroNav,videoNav,moreNav, nil];
    myTabBar.tabBar.backgroundImage = [UIImage imageNamed:@"tabbar1.png"];

    self.window.rootViewController = myTabBar;
//----------------------------------------------------------------------
    [newsNav release];
    [newsVC release];
    [videoNav release];
    [videoVc release];
    [heroNav release];
    [heroVC release];
    [moreNav release];
    [moreVC release];
    [myTabBar release];
    [_window release];
    
////---------------添加程序开始动画------------------------------------------
//    
//    UIImageView *view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.window.frame.size.width / 2, self.window.frame.size.height)];
//    view.backgroundColor = [UIColor orangeColor];
//    view.image = [UIImage imageNamed:@"FlashLeft.png"];
//    [self.window addSubview:view];
//    
//    UIImageView *view1 = [[UIImageView alloc] initWithFrame:CGRectMake(self.window.frame.size.width / 2, 0, self.window.frame.size.width / 2, self.window.frame.size.height)];
//    view1.backgroundColor = [UIColor orangeColor];
//    view1.image = [UIImage imageNamed:@"FlashRight.png"];
//    [self.window addSubview:view1];
//    
//
//    
//    [UIView animateWithDuration:2 delay:1 usingSpringWithDamping:1 initialSpringVelocity:0.5 options:UIViewAnimationOptionLayoutSubviews animations:^{
//    
//    view.frame = CGRectMake(-self.window.frame.size.width / 2, 0, self.window.frame.size.width / 2, self.window.frame.size.height);
//    view1.frame = CGRectMake(self.window.frame.size.width, 0, self.window.frame.size.width / 2, self.window.frame.size.height);
//    
//        } completion:^(BOOL finished) {
//        
//    [view removeFromSuperview];
//    [view1 removeFromSuperview];
//
//            
//        }];

//----------------------------------------------------------------------
    
    
   
    
    
   NSUserDefaults * state = [NSUserDefaults standardUserDefaults];
    
    if ([state objectForKey:@"state"] == nil) {
        
       
        NSArray *coverImageNames = @[@"wudier.png", @"jie.png", @"kapai.png"];
        NSArray *backgroundImageNames = @[@"IMG_1220.png", @"IMG_1221.png", @"IMG_1223.png"];
        
        self.introductionView = [[ZWIntroductionViewController alloc]initWithCoverImageNames:coverImageNames backgroundImageNames:backgroundImageNames];
        [self.window addSubview:self.introductionView.view];
        
        __block AppDelegate *weakSelf = self;
        self.introductionView.didSelectedEnter = ^() {
            [weakSelf.introductionView.view removeFromSuperview];
            weakSelf.introductionView = nil;
            
        };
        
    }
    
   
    [state setObject:@"on" forKey:@"state"];
    
    return YES;
}




















- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
